@using BTCPayServer.Client
@using Microsoft.AspNetCore.Mvc.TagHelpers
@using BTCPayServer.Views.Apps
@using BTCPayServer.Plugins.Crowdfund
@using BTCPayServer.Services.Apps
@inject AppService AppService
@model BTCPayServer.Components.MainNav.MainNavViewModel
@{
    var store = Context.GetStoreData();
}

@if (store != null)
{
    var appType = AppService.GetAppType(CrowdfundAppType.AppType)!;
    var apps = Model.Apps.Where(app => app.AppType == appType.Type).ToList();
    <li class="nav-item" permission="@Policies.CanModifyStoreSettings">
        <a layout-menu-item="CreateApp-@appType.Type" asp-area="" asp-controller="UIApps" asp-action="CreateApp" asp-route-storeId="@store.Id" asp-route-appType="@appType.Type">
            <vc:icon symbol="nav-crowdfund" />
			<span text-translate="true">Crowdfund</span>
        </a>
    </li>
    @if (apps.Any())
    {
        <li layout-menu-item="CreateApp-@appType.Type" class="nav-item" not-permission="@Policies.CanModifyStoreSettings" permission="@Policies.CanViewStoreSettings">
            <span class="nav-link">
                <vc:icon symbol="nav-crowdfund" />
				<span text-translate="true">Crowdfund</span>
            </span>
        </li>
    }
    @foreach (var app in apps)
    {
        <li class="nav-item nav-item-sub" permission="@Policies.CanViewStoreSettings">
            <a layout-menu-item="@nameof(CrowdfundPlugin)-@app.Id" asp-area="" asp-controller="UICrowdfund" asp-action="UpdateCrowdfund" asp-route-appId="@app.Id">
                <span>@app.AppName</span>
            </a>
        </li>
        <li class="nav-item nav-item-sub" not-permission="@Policies.CanViewStoreSettings">
            <a layout-menu-item="@nameof(CrowdfundPlugin)-@app.Id" asp-area="" asp-controller="UICrowdfund" asp-action="ViewCrowdfund" asp-route-appId="@app.Id">
                <span>@app.AppName</span>
            </a>
        </li>
    }
}
